import React, { Component } from 'react'

// 引入数据源
import Mycontext from '../store'

export default class Cmp2 extends Component {
  // 只得到了默认数据 --> 没有包裹在Provider组件中
  static contextType = Mycontext

  render() {
    return (
      <div>
        <button onClick={this.setCount.bind(this)}>自增数据</button>
      </div>
    )
  }
  setCount() {
    this.context.setCount()
  }
}
